package com.newland.zxy.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : zhangxuyuan
 * @Project: springcloudoauth2
 * @Package com.newland.zxy.controller
 * @date Date : 2021年02月05日 13:53
 */
@RestController
@RequestMapping("/test")
public class TestController {


    @GetMapping("/index")
    public String index()
    {
        OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails)SecurityContextHolder.getContext().getAuthentication().getDetails();
        System.out.println("-------------------------------");
        System.out.println(details);
        System.out.println(details.getClass().getName());
        System.out.println(details.getDecodedDetails().getClass().getName());
        System.out.println(details.getDecodedDetails());
        return "test-index";
    }
}
